package jrpc

import (
	"context"
	"encoding/json"
	"fmt"

	"github.com/osamingo/jsonrpc/v2"
	"github.com/zeromicro/go-zero/core/logc"
)

func RegisterMethod() {
	Register(&{{.upperStartCamelObject}}FindOneBy{{.upperField}}Func{})
}

type {{.upperStartCamelObject}}FindOneBy{{.upperField}}Params struct {
	{{.in}}
}

type {{.upperStartCamelObject}}FindOneBy{{.upperField}}Result struct {
	*{{.upperStartCamelObject}}
}

type {{.upperStartCamelObject}}FindOneBy{{.upperField}}Func struct {
	{{.upperStartCamelObject}}FindOneBy{{.upperField}}Params
	{{.upperStartCamelObject}}FindOneBy{{.upperField}}Result
}

func (t *{{.upperStartCamelObject}}FindOneBy{{.upperField}}Func) Name() string {
	return fmt.Sprintf("%s.%s", {{.table}}, "FindOneBy{{.upperField}}")
}

func (t *{{.upperStartCamelObject}}FindOneBy{{.upperField}}Func) ServeJSONRPC(c context.Context, params *json.RawMessage) (result any, err *jsonrpc.Error) {
	logc.Infof(c, "%s( %v )", t.Name(), *params)
	return nil, nil
}

func (t *{{.upperStartCamelObject}}FindOneBy{{.upperField}}Func) Params() any {
	return t.{{.upperStartCamelObject}}FindOneBy{{.upperField}}Params
}

func (t *{{.upperStartCamelObject}}FindOneBy{{.upperField}}Func) Result() any {
	return t.{{.upperStartCamelObject}}FindOneBy{{.upperField}}Result
}
